<template>
  <view class="yuongjin">

    <view class="form">
      <u-form :border-bottom="false" :model="form" ref="uForm" label-width="180">
        <u-form-item required label="提现金额">
          <u-input v-model="form.sum" placeholder="输入提现金额" />
        </u-form-item>
        <u-form-item label=" ">
          <view>
            <view class="tip">可提现金额￥{{ data.balance ? data.balance : '0' }}</view>
            <view class="tip">最低提现金额￥200|手续费率0.6%</view>
          </view>
        </u-form-item>
        <u-form-item required label="提现方式">
          <view class="all-election">
            <view class="iconfont icon-yuan_checked color-base-text"></view>
            <text>银行卡</text>
          </view>
        </u-form-item>
      </u-form>

      <view class="typeMoney" @click="redirect('/pages_promotion/member/bankCard')">
        <view class="flex">
          <image src="https://runshui.oss-cn-shenzhen.aliyuncs.com/171f1a7ea65dc8cf41d85be0a143618.png" class="img" />
          <view>
          <text>
            提现到银行卡
          </text>
          <view class="bank_number">{{ data.bank_number ? data.bank_number : '未设置银行卡' }}</view>
          </view>
        </view>
        <u-icon name="arrow-right" color="#8e8e8e"></u-icon>
      </view>
    </view>

    <view class="btn1" @click="apply">
      申请提现
    </view>
    <view class="btn2" @click="redirect('/pages_promotion/member/recordList')">提现记录</view>
  </view>
</template>

<script>
export default {
  components: {
  },
  mixins: [],
  data() {
    return {
      form: {
        sum: '',
      },
      data: {}
    }
  },
  onShow() {
    this.liandonginfo()
    this.$api.sendRequest({
      url: "/api/member/judgeBuy",
      success: res => {
        console.log(res,'/api/member/judgeBuy');
        if(!res.data){
          uni.hideShareMenu()
        }
      }
    });
  },
  onLoad(data) {
    },
  methods: {
    apply() {
      if (this.form.sum < 200) {
        this.$util.showToast({
          title: '小于最低提现金额'
        });
        return;
      }
      this.$api.sendRequest({
        url: '/api/member/liandongwithdrawal',
        data: {
          money: this.form.sum
        },
        success: res => {
          console.log(res, 'res');
          if(res.code < 0) {
            this.$util.showToast({
              title: res.message
            });
            return;
          }else {
            // 回退
            this.$util.showToast({
              title: '成功提现'
            });
            this.liandonginfo()
            // this.$util.goBack();
          }
        }
      });
    },
    liandonginfo() {
      this.$api.sendRequest({
        url: '/api/member/liandonginfo',
        success: res => {
          this.data = res.data
          console.log(this.data, 'this.data');
        }
      });
    },
    redirect(url) {
      this.$util.redirectTo(url);
    },
  },
  onShareTimeline() {
    return {
      title: '鹏城快享',
      query: `source_member=${uni.getStorageSync("user_id")}`,
      imageUrl: ""
    }
  },
  onShareAppMessage() {
    return {
      title: "鹏城快享",
      path: `/pages/index/index?source_member=${uni.getStorageSync("user_id")}`,
      imageUrl: ''
    }
  },
};
</script>

<style lang="scss" scoped>
@import '@/common/css/diy.scss';

.yuongjin {
  margin: 20rpx 30rpx;
  padding-bottom: 30px;

  .form {
    background-color: #fff;
    padding: 10px 20px;
    border-radius: 10px;

    .all-election {
      display: flex;
      gap: 5rpx;
    }



    .color-base-text {
      color: #1aac19 !important;
    }
  }
}

.tip {
  color: #999;
  line-height: initial;
}

.typeMoney {
  display: flex;
  justify-content: space-between;
  background: #f8f8f8;
  border-radius: 10px 20px;
  margin: 15px 0;
  padding: 10px;

  .flex {
    display: flex;
    align-items: center;
  }

  .bank_number {
    color: #999;
    margin-top: 10rpx;
  }

  .img {
    width: 30px;
    height: 30px;
    margin-right: 5px;
  }
}

.btn1 {
  background-color: #1aac19;
  padding: 10px 0;
  text-align: center;
  color: #fff;
  border-radius: 10px;
  margin-bottom: 10px;
}

.btn2 {
  padding: 10px 0;
  text-align: center;
  color: #666;
  border-radius: 10px;
}
</style>

